package pl.fit.app;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class MainWindow extends JFrame implements ChangeListener {

	private JMenuBar topMenu;
	private JPanel clientsPanel;
	private Clients clients;
	private JTabbedPane tabs;

	public MainWindow() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(new Dimension(800, 600));
		setLocation(125, 125);

		clientsPanel = new JPanel();
		topMenu = new TopMenu();
		clients = new Clients();
		tabs = new JTabbedPane();
		tabs.addChangeListener(this);

		clientsPanel.setLayout(new BorderLayout());
		clientsPanel.add(clients, BorderLayout.CENTER);
		tabs.add("Clients", clientsPanel);
		tabs.add("Staff", new JPanel());
		tabs.add("Accountancy", new JPanel());
		setJMenuBar(topMenu);
		add(tabs, BorderLayout.CENTER);
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		switch (tabs.getSelectedIndex()) {
		case 0:
			topMenu = new ClientsMenu();
			break;
		case 1:
			topMenu = new TopMenu();
			break;
		case 2:
			topMenu = new TopMenu();
			break;
		default:
			break;
		}
		setJMenuBar(topMenu);
	}
}
